package com.runshu.newsmartark.adapter;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.runshu.newsmartark.R;
import com.runshu.newsmartark.entity.LogsManagerBean;

import java.util.List;

/**
 * Demo class
 *
 * @author yu
 * @date 2020/8/27
 * @decs：
 */

public class MyLogsAdapter extends BaseQuickAdapter<LogsManagerBean.ContentBean, BaseViewHolder> {
    public MyLogsAdapter(@Nullable List<LogsManagerBean.ContentBean> data) {
        super(R.layout.item_my_logs, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, LogsManagerBean.ContentBean item) {

        helper.setText(R.id.tv_no, String.valueOf(helper.getAdapterPosition() + 1));
        helper.setText(R.id.tv_code, item.getUserCode());
        helper.setText(R.id.tv_name, item.getUsername());
        //0是补货 1 领取 2 归还 3 退货
        if ("0".equals(item.getType())){
            helper.setText(R.id.tv_pro_change_state, "补货数量" );
            helper.setText(R.id.tv_change_num,  "+" + item.getOperationNumber());
            helper.setTextColor(R.id.tv_change_num, mContext.getResources().getColor(R.color.color_FF1DD483));
        }else if ("1".equals(item.getType())){
            helper.setText(R.id.tv_pro_change_state, "领取数量" );
            helper.setText(R.id.tv_change_num,  "-" + item.getOperationNumber());
            helper.setTextColor(R.id.tv_change_num, mContext.getResources().getColor(R.color.color_F15555));
        }else if("2".equals(item.getType())){
            helper.setText(R.id.tv_pro_change_state, "归还数量" );
            helper.setText(R.id.tv_change_num,  "+" + item.getOperationNumber());
            helper.setTextColor(R.id.tv_change_num, mContext.getResources().getColor(R.color.color_FF1DD483));
        }else {
            helper.setText(R.id.tv_change_num,  "-" + item.getOperationNumber());
            helper.setTextColor(R.id.tv_change_num, mContext.getResources().getColor(R.color.color_F15555));
            helper.setText(R.id.tv_pro_change_state, "退货数量" );
        }
        helper.setText(R.id.tv_create_date, item.getCreateTime());


    }
}